package com.qms.tubu.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;

import com.qms.tubu.R;
import com.qms.tubu.application.TubuApplication;
import com.qms.tubu.tools.SPHelper;

import cn.sharesdk.framework.ShareSDK;

/**
 * Created by Mad on 2015/7/2.
 */
public class WelcomeActivity extends BaseActivity{
    private Handler mHandler=new Handler();
    private Runnable mRun=new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(getApplicationContext(),MainActivity.class));
            finish();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        isFirstRun();
        mHandler.postDelayed(mRun, 2000);

    }
    private boolean isFirstRun()
    {
        SharedPreferences preferences=getSharedPreferences(SPHelper.SP_CONFIG,MODE_PRIVATE);
        boolean is=preferences.getBoolean("first_run",true);
        if(is)
        {
            DisplayMetrics md=new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(md);
            SharedPreferences.Editor editor=preferences.edit();
            editor.putInt("screen_width",md.widthPixels);
            editor.putInt("screen_height",md.heightPixels);
            editor.putBoolean("first_run",false);
            editor.commit();
        }
        return is;
    }

    @Override
    public void onBackPressed() {
       return;
    }
}
